<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <h:body>
        <ui:composition template="WEB-INF/template/master.xhtml">




            <ui:define name="header">
                  <!-- HEADER -->
                <div data-role="header" data-theme="a" data-position="inline">
                    <a href="options.xhtml" data-thema="a" data-iconpos="notext" class="ui-btn-left" data-icon="gear"></a>
                    <h1>Prüfungen</h1>
                </div>
            </ui:define> 

            <ui:define name="content">
                <!--Wenn ID-Courseschedule korrekt-->
                <c:if test="#{timetableBean.validateParameter()== true}">                    
                    <div data-role="content" data-theme="a">
                        <c:set var="lastExam" value="test" />
                        <c:forEach var="Lecture" items="#{timetableBean.getLectureCollectionbyCourseSchedule()}">
                            <c:choose>
                                <c:when test="#{Lecture.getExam() == null}">
                                    <ul data-role="listview" data-inset="true" data-theme="b">
                                        <li>
                                            <p class="ui-li-desc-exams-null">Für <b>#{Lecture.getLecname()}</b> liegen noch keine Prüfungstermine vor!</p>
                                        </li>
                                    </ul>
                                </c:when>
                                <c:otherwise>
                                    <!--//When aktuelles Datum ungleich dem Vorherigen ist gib neuen Header aus-->
                                    <c:if test="#{Lecture.getExam().getExamdate()!=lastExam}">
                                        <c:set var="lastExam" value="#{Lecture.getExam().getExamdate()}" />
                                        <ul data-role="listview" data-inset="true" >
                                            <li data-role="list-divider">#{Lecture.getExam().getExamdateShort()}</li>
                                        </ul>
                                    </c:if>

                                    <c:choose>
                                        <c:when test="#{Lecture.getExam().isUpdate() == true}">
                                           <!-- <ul data-role="listview" data-inset="true" >
                                                <li>-->
                                           <div data-role="collapsible" data-theme="a" data-content-theme="b">
                                                <h3>#{Lecture.getLecname()} <div class="ui-exams-update-top">UPDATE</div></h3> 
                                                        
                                                        <p class="ui-li-exams-heading-2">#{Lecture.getExam().getExamroom()}</p>
                                                        <p class="ui-li-exams-heading-3">#{Lecture.getExam().getStarttimeShort()}</p>
                                                        <p class="ui-li-desc-exams-sec">#{Lecture.getExam().getInfoexam()}</p>
                                                        <p class="ui-li-desc-exams-sec">#{Lecture.getExam().getFirstexaminer().getName()}</p>
                                                        <p class="ui-li-desc-exams-sec">#{Lecture.getExam().getSecondexaminer().getName()}</p> 
                                                        <p class="ui-exams-update-bottom">aktualisiert am: #{Lecture.getExam().getTimestampexamShort()}</p>
                                           </div>
                                                <!--</li>
                                            </ul>-->
                                        </c:when>
                                        <c:otherwise>
                                            <div data-role="collapsible" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-theme="a" data-content-theme="a">
                                                <h3>#{Lecture.getLecname()}</h3> 
                                                <p class="ui-li-exams-heading-1">#{Lecture.getExam().getExamroom()}</p>
                                                <p class="ui-li-exams-heading-2">#{Lecture.getExam().getStarttimeShort()}</p>
                                                <p class="ui-li-desc-exams-sec">#{Lecture.getExam().getInfoexam()}</p>
                                                <p class="ui-li-desc-exams-sec">#{Lecture.getExam().getFirstexaminer().getName()}</p>
                                                <p class="ui-li-desc-exams-sec">#{Lecture.getExam().getSecondexaminer().getName()}</p>
                                            </div>
                                        </c:otherwise> 
                                    </c:choose>

                                    <c:if test="#{Lecture.getExam().isUpdate() == true}">

                                    </c:if>

                                </c:otherwise>
                            </c:choose>
                        </c:forEach>

                    </div> 
                </c:if>
            </ui:define>

            <ui:define name="footer">
                <!-- Footer -->
                <div data-role="footer" data-theme="a" data-position="fixed" data-id="day_week_exams">

                    <div data-role="navbar" data-theme="a">
                        <ul>

                            <li><a href="day.xhtml?schedule=#{timetableBean.coursescheduleid}&amp;rand=#{timetableBean.getRandomForURL()}">Heute</a></li>
                            <li><a href="week.xhtml?rand=#{timetableBean.getRandomForURL()}" id="week">Woche</a></li>
                            <li><a class="ui-btn-active" href="exams.xhtml?rand=#{timetableBean.getRandomForURL()}">Prüfungen</a></li>
                        </ul>


                    </div>
                </div>
            </ui:define>

        </ui:composition>
    </h:body>
</html>
